Treasury Secretary Hank Paulson finally blinked, but that doesn't mean Fannie Mae (NYSE:FNM) and Freddie Mac (NYSE:FRE) shareholders are out of the woods. After a stunning week in which the government-sponsored enterprises (GSEs) saw nearly half their stock market value erased, the Treasury and the Federal Reserve announced three measures to reassure the market.

First, the Fed will allow Fannie and Freddie to borrow from it to avert a short-term funding crisis, just as it did for investment banks such as Lehman Brothers (NYSE:LEH) or Merrill Lynch (NYSE:MER) in March. This is a stopgap measure until the cap on Freddie and Fannie's lines of credit with the government can be increased. Also, the Treasury has announced that it is ready to bolster the firms' capital through an equity investment. But how did we get into this mess in the first place?

Looking back two years ago
Maybe I shouldn't be surprised that it has come to this. As I wrote about Fannie Mae in a Motley Fool article two years ago:

If I analyze Fannie Mae as a business rather than a government program, I can't find any competitive advantage, aside from favorable borrowing costs based on the perception of implicit government backing.... So when the government signals that it is uncomfortable with a guarantee that it never gave, and wants to reduce the influence of the GSEs, investors must take a hard look at these companies' business models.

The worse they behaved, the more they were supported
If I'd followed my own advice to its logical conclusion, I might have realized that the current crisis was inevitable, or at least highly likely -- because the 'shareholder-owned GSE' model is inherently unstable. As government-sponsored enterprises, Fannie and Freddie are chartered by Congress to provide liquidity in the U.S. mortgage market, and to promote affordable home ownership. Investors naturally believed that the U.S. government would act as ultimate guarantor on their debt, enabling the government-sponsored enterprises to obtain lower-cost funding than their competitors.

However, the GSEs serve a second master: their shareholders, who require profit growth to stay happy. Growth is what they got, as Fannie and Freddie increased the size of their commitments, despite inadequate capital and poor risk management. After all, what's the worst that can happen when you've got Uncle Sam (i.e. taxpayers like you and me) ready to foot the bill in a worst-case scenario?

This is a textbook illustration of moral hazard at work -- a situation in which the government's implicit backing created a one-sided bet that encouraged management to take on ever-greater amounts of risk. Perversely, the more risk they took on, the less the government could allow them to fail.

As a government-chartered duopoly, Fannie and Freddie were the ultimate golden-egg-laying goose. It now looks like greed and short-sightedness have led their managers and Congressional backers to cook that goose.

Where does that leave shareholders?
One thing is certain: It's no use going to Hank Paulson hat in hand. If the government does make an equity investment through common or preferred stock, Paulson will have no problem heavily diluting existing shareholders. Recall that when JPMorgan Chase (NYSE:JPM) CEO Jamie Dimon mentioned he was considering a bid for Bear Stearns in a range of $4 to $5 a share, Paulson responded: "That sounds high to me. I think this should be done at a low price." (Dimon then lowered his first bid to $2 per share.)

Why the hard-line stance? In order to discourage moral hazard, Paulson doesn't want to be seen to be handing out a free lunch to investors. In other words, owning stocks is about juggling risk and return -- don't expect to achieve huge returns (something Fannie and Freddie shareholders did for many years) without taking any risk. I couldn't agree more.

Where else could this happen?
What are the wider lessons for investors? Monopolies or oligopolies protected by government or regulatory fiat benefit from a moat that is extraordinarily difficult for would-be competitors to cross. However, holed up comfortably in their castles, the managements of these firms are vulnerable to a plague from within the castle walls. It is imperative that shareholders periodically check to ensure that these great businesses are led by honest, properly incentivized managers.

Another protected sector that must now be reevaluated: credit rating agencies such as Moody's (NYSE:MCO) and Standard & Poor's, a unit of McGraw-Hill (NYSE:MHP). As Nationally Recognized Statistical Rating Organizations designated by the SEC (at one time, there were only three), these firms are enmeshed in the fabric of the financial markets. However, it now appears that they abused their privileged position during the credit bubble.

While the rating agencies aren't facing the sort of pressing financial risks that have tripped up the GSEs, they may well be forced to operate in a very different regulatory environment in the future. Politicians and regulators are scrambling to come to grips with the credit meltdown, and there is nowhere for these companies to hide. Different rules could mean lower profits; they don't always rise, as investors are discovering in this post-bubble world.

Related Wall Street Foolishness: