Some alarms can go for decades - might just need the cover popped off and the sensor (usually shiny metal canister) blown out every few years - dust gets in the sensor and causes them to go off after awhile. I have ones I test yearly at fall daylight savings time changeover (this week, in fact) that are 35 years old and still work fine. In all, I have only had one go bad - a transistor failed. I would suggest you get a can of fire alarm test spray - looks like a can of compressed air, but has a compound in it that simulates smoke - just a quick shot to test each alarm, a can for about $5 at Radio Shack or a home improvement store or lumberyard, lasts 5+ years in my house, with about 20 alarms all told tested once yearly.
Others, the more modern ones, have a built-in timer that makes them say they are dead - typcially after 8-10 years - called planned obsolesence.
A Handyman or an electrician can install either, assuming you are not installing NEW wiring to a new one (in which case you want an electrician). As other comment said, battery operated ones are easy to replace yourself - all the fasteners you could need come with them, and with good instructions.
For my money, don't skimp a few $ by getting an off-brand - get First Alert, Kiddee, or 3M. In bedrooms and halls I recommend STRONGLY that you get the type with a light also - takes 2 batteries - one for the alarm, one for the light. When you change the alarm battery each year, it still has plenty of juice for light use in most cases. So few people realize that if you have an electrical fire or a fire near the electrical panel or a fire following a tornado or hurricane or earthquake hit you may lose electricity, so having the lighted ones (about $5 more) can make the difference between getting out of the house safely or not, particularly if small children are involved.
Run about $10-15 for simplest to about $50-60 each for ones that are smoke, combustion product, and carbon monoxide detectors all in one and are hard-wired into house circuitry. Available almost anywhere - Amazon, box stores, home improvement centers, electrical supply houses, large grocery stores even.
A tbought on the one that went off- is there any chance it was picking up combustion products from a furnace or hot water heater, or from a smoldering fire in a fireplace or wood stove ? It might not be defective at all - just doing its job - Ionization types can pick up very small amount of combustion products. I would try a different battery - make sure you use a brand new one, and check it is hooked in correctly and securely in the sockets - put in with wrong terminals in wrong places and it will sometimes sound alarm.