"Ma'am" and "sir" are a bit more formal than what you would normally expect to find in a typical setting when you are surrounded by strangers. Both of these words are usually used by people who are talking to someone who you want to know that you respect them (a boss, the parents of a girlfriend, your own parents, teachers/professors, etc). "Excuse me" is really one of the only ways to get someone's attention if you don't know their name and still want to be polite, after that it is really just a matter of making it clear who you are wanting to talk to with body language, such as making eye contact or gesturing to them to get their attention.