All men change, as do all women. We are the sum of how our experiences interact with our personality and character. Hearing that there's a pregnancy definitely qualifies as a big experience, and can be expected to bring about a big change, especially initially. In some cases it just means that someone stops hiding an aspect about themselves that they previously didn't let you see. Sometimes it's a temporary reaction to such life-changing news. Other times it's due to uncertainty as well as interacting with your changes at the same time.
I will say that with each of my pregnancy announcements, my husband changed permanently...and so did I. The changes are not always bad (though they can be), and in some cases it's just learning how to make room for a completely dependent life within your own. If a guy cuts and runs the moment he hears about a pregnancy, chances are the problem is that he's not mature enough to deal with the consequences of his own actions and put himself aside to take care of a child. In such a case, the change is probably just that you can now see that part of him. If it's just that his behavior toward you is suddenly different but he still wants a relationship, then give him some time -- he could just be working on adjusting to the new reality.