You can't just dump some bytes into a file and expect that they magically become something else.
Do some research on the source data format (M4A) and the destination format (WAV), learn how to extract the raw audio data from the source, convert it and then write a valid file in the destination format.
Here is a link to some information on the WAV format:
RIFF WAVE – Wikipedia[
^]