The short answer: Beer is susceptible to whatever can live in the wort/beer given it's specific condition at the time. As fermentation continues, fewer and fewer micro-organisms are able to colonise the beer.
The wort-production process gradually increases the sugar content, and importantly lowers the pH of the beverage as each stage progresses.
There's lots of interactions happening during the mash, where the bulk of the changes happen. One of the major pH drops is from precipitation of phosphates and other minerals. The next step, boiling further acidifies and concentrates the wort.
At the end of the boil, the wort is sanitary, and commonly hops have been added.
It has (or should have) an acidic (low) pH around 5.2 - 5.4.
The sugar content varies, but an "average" beer commonly has a specific gravity around 1.050.
Before the yeast is added, the wort is a moderate sugary liquid. All sorts of bacteria and fungi are happy to grow in this, especially if it is warm. The brewer needs to keep this in sanitary conditions to prevent the entry of unwanted micro-organisms.
The yeast is then added (now the wort is beer).
The yeast consumes the sugars quickly, using oxygen, and producing ethanol & CO2. But it also further drops the pH. The yeast is making a liquid that is hostile to other micro-organisms.
Eventually most of the simple sugars are converted to ethanol. During this process the yeast has also absorbed ammonium ions and excreted organic acids - this is where the fermentation pH drop comes from. By this time nearly all of the dissolved oxygen in the liquid is gone. The finished beer should have a pH of around 4.5 (lager), with ales being a little more acidic (down to 3.8).
So, The yeast over-time changes its environment to somewhat perfectly suit itself, but also against others. So ideally a quick fermentation is best. The low pH on its own prevents lots of spoilage organisms that cannot survive in the relative acidity.
Looking at some common spoilage micro-organisms:
Acetobacter - this likes to convert ethanol into acetic acid, but it needs oxygen. In the initial stages of fermentation the oxygen is quickly used up.
Lactobacillus - converts sugar into lactic acid. The hops contain compounds which help prevent many different varieties of lacto' growing.
Pediococcus are a very a common source of beer infection, they are a type of Lactobacillus. Unfortunately they are not so effected by hops.
This is a really complicated subject, I hope I was able to explain things in a somewhat simple manner.
Further Reading:
https://byo.com/article/the-principles-of-ph/
http://beerandwinejournal.com/proper-boil-ph/
http://www.milkthefunk.com/wiki/Lactobacillus
http://draftmag.com/brettanomyces-lactobacillus-pediococcus-beer/
Update after comment/question: One further source of infection can be from different sub-species of yeast. Generally speaking, common brewer's yeast only ferments simple sugars (up to 3-glucose-molecule sized). So the yeast may have fully done it's job, consumed everything it can, and thus the beer is "finished". But other yeasts, Brettanomyces in particular, are able to consume larger sugars. So theoretically, brettanomyces could colonise finished beer, fermenting the remaining sugars. Same as other yeasts, "brett" converts the sugars in to CO2+ethanol, but it also produces different (perhaps unwanted) flavour compounds. If this is happening in a bottle, it may cause excess carbonation and significant changes in sweetness. In pre-Louis Pasteur / pre-Emil Hansesn times, most beer probably always contained some level of this yeast. But now-days, modern beer is (for the most part) a single-strain fermentation (or at least controlled-strain combination). There are a some contradictory examples to this statement (lambics, sours, etc.), but the statement is essentially true: The vast majority of modern beer is a controlled environment process.
Given this is a homebrew Q&A, I want to add this: Despite all the things that can theoretically happen, generally with good sanitation practices and an adequate amounts of yeast, your beer will ferment beautifully. Just like it has been doing for thousands of years.