They are basically synonyms. One is just more formal.
That's right, the meaning is the same and one is more formal. "Czemu" is considered a bit rude, an evidence of lack of manners. Well bred ladies / gentlemen do not ask "czemu?" or "co?", they use "dlaczego" and "proszę? / słucham?" instead :]