Fannie Mae and Freddie Mac rejoin the federal government

Can someone explain why the government created companies that are now run by private shareholders? I'm having trouble understanding what the advantage is. Taxpayers are still clearly at risk so it seems that the shareholders can capitalize and then, should something go wrong, taxpayers will have to bail them out. Wouldn't it be better to have these institutions run by the government entirely?...