You're right, sometimes someone else will find a block before you and will add it onto the longest existing chain. IF you always appended your bad blocks to the longest chain then the blockchain would look something like bad->bad->good->bad->bad->good->bad->bad. BUT you WONT be adding your blocks to the longest chain. You will always add your blocks to YOUR OWN last bad block. So you will always be working on a blockchain that looks like ... ->bad->bad->bad->bad. And since you have 51% of the power your blockchain will eventually always be longer than the other chain(s) miners are working on. For a while the two chains (legitimate and your bad one) will go back and forth between which is longer. But at some point yours will get long enough and outpace the legitimate one.
If you don't understand this you don't understand how bitcoin works. I don't say this to be a dick, but I say it because this is a real concern that a lot of people don't realize or think about.