If a memory card has some bad cells, you will occasionally hit one of them, when the camera tries to save a file.
You should try doing a low level card format, there should be a option to select it on the Format screen. A low level format writes to every memory location and will find / mark bad and defective spots. A conventional format does not check the cells, it merely marks them as available to overwrite in the FAT table.
Then, the camera body attempts to erase a sector before writing to it and it hangs.
A low level format of a SD card should be done once every few uses or whenever a problem crops up.
If the issue continues, most cards are guaranteed for 5 years or even life, so send it in to be replaced.