He did because he rightly thought Napoleon was going to save France from the Terror. But after seeing Napoleon's imperialist actions, he scratched out the dedication and replaced it with "to a once great man." He came to hate Napoleon.
Beethoven wrote his third symphony in 1803. By that time the Terror had been over for almost a decade and Napoleon was well on his way to waging war against most of Europe. It’s only when he declared himself Emperor in 1804 that Beethoven drew the line. By that time the symphony was already finished and was merely re-titled Eroica (the original title was Bonaparte).