Sonic's fear of water is a long-standing part of his character. Any viewer of Sonic Underground — which first aired on 30 August 1999 — or the earlier cartoons will remember that the episodes repeatedly describe his hydrophobia as a genuine, deep-seated terror rather than a mild dislike.
If you want the actual explanation behind it, Sonic X is the place to look: the series dedicates screen time to why he reacts the way he does. Watch through its episodes and the reason becomes clear.