If you want the mayor, you can limit your population cap to 50-ish dwarves (or anything below 140 really, but the lower you keep it, the easier it will be for the other part, so I recommend just setting to 50).
Baron/Count/Duke can show up as low as 20-pop unfortunately, but you can slow/stop their appointment by not producing much wealth (which... will work for a while but eventually you'll probably break that amount anyway). After that, when the trade liaison from your civ comes and offers you a barony, you can keep declining the offer so that you can avoid getting a baron/count/duke from there. Note, that if you never get at least a baron, the trade caravans from your civ will never get wagons, so the caravans will stay just packbeasts and relatively small. And if you DO get a baron, I don't think you can decline the promotion to count/duke after that, so it's kinda all-or-nothing there.
As for Queen/barons just appearing due to inheriting titles... that's not something you can directly avoid, because it's events outside of your control that are causing that. It means that outside of your fort, some war or other event killed your civ's current queen/nobles/etc or destroyed their homes, so they came to you. The only way you can try to 'avoid' this is at embark, try to pick the largest dwarf civ to join and the one with the most locations/sites. Then the civ's current queen/nobles are (a) less likely to get killed by war/etc because they're pretty dominant already, and (b) if they DO still get killed somehow, there's lots of other places for them to go to, so it's less likely they'll come join you. Not impossible, but a lot less likely.
This stuff is, at least, my experience. ^_^ I did hold out without a baron for awhile by declining the appointment, but eventually I gave in, lol. I wanted those wagons! One thing you can do to reduce the annoyance of the baron/count/duke is to survey your dwarves beforehand and pick someone who likes items that you don't mind producing constantly (and not being able to sell). My current baron for instance likes gauntlets. So I make them whenever demanded (fulfills the mandate), then melt down all the non-masterpieces (melting doesn't bother the baron, only selling does). Masterpieces go into a stockpile for the military. I do have more gauntlets than I need, really, but it's not too bad so far.
Also note that mayors make demands too. And since those are elected it's harder to control which dwarf it ends up being. But try to keep social skills high on a dwarf with demands you won't mind fulfilling! xD