I'm interested in the introduction of bacteria on Mars. If a small base were set up with attempts to maintain some sort of sterilisation protocols, but all the humans died on that base a) what would happen to the bodies and b) what would happen to the bacteria contained within the bodies themselves?
Mars is a very dry place, so the bodies would quickly desiccate. (About the only way this could be escaped is if the bodies just happened to be positioned partway down the equator-facing wall of a crater which happens to intersect water-bearing strata just as they produce some of their rare seepage... In other words, not very easily.)
The desiccation would stop all microbial life and the body would effectively mummify as bodies have mummified in desert areas on Earth when undisturbed by animals -- remember that Mars is nearly everywhere drier than Terrestrial deserts. Desiccation would be very quick: days, not months.
What would happen afterwards? First, some bacteria respond to desiccation by going onto a spore stage. I don't know if any of those are the bacteria commonly found in tissue, though it seems unlikely since tissue-resident bacteria would not need that adaptation very often. But maybe some do.
If the mummy later encountered water -- a rare surface flow or water from a future terraforming project -- some bacteria might re-activate and go on about their lives, munching away on the organics until either the organics or the water ran out. Then they'd go back to being spores with little chance of a second revival.
The countervailing effect is that the Martian surface is dangerous to life in other ways than simple dryness. Highly oxidizing compounds such as perchlorates are common in the Martian soil and these would oxidize the mummy's organics. (I can't estimate how quickly, but probably more quickly than air oxidizes mummies on Earth.) They'd also instantly kill any bacteria or bacterial spores they encountered.
Additionally, UV radiation is strong, and this also would tend to destroy organics on the surface.
Probably the best chance of long-term survival would be if the body was covered by a dune which would shield it from the UV and leave it in unchanging soil so that once the nearby perchlorates (etc.) were used up, what was left would probably remain for quite a while.
But even bacterial spores are not eternal -- DNA degrades from random molecular motion and quantum mechanical effects -- so that there is some limit after which even the most carefully preserved spores would not revive.
The sterilization protocols strike me as more of self-sustaining a bureaucracy than as a needed precaution. (Especially since rocks from Earth probably are thrown to Mars fairly frequently.)
Bacteria will stay alive as long as it receives resources. Like any other organism, bacteria also needs oxygen, water, and resources to produce amino acids. These are necessities. So after using all the resources of the dead body, the bacteria will die.
If you are asking if bacteria can evolve and survive, that would be a topic of research and sci-fi.