Burglar alarms do work to deter burglars in most cases.
If you have a burglar alarm installed you should also have a burglar alarm sign on your window and in your yard where the burglar can see the sign.
Usually if a burglar sees signs that your house has burglar alarms in it then the burglar will avoid your house because they do not want to be detected and want a house to break into that has no burglar alarm where they won't be caught.
Still even people break into businesses that have burglar alarms as well so they do not always deter burglars but having a burglar alarm can help.
The best burglar alarm is one that automatically connects to the police so that if someone were to break into your home the police would be automatically notified of the break in.