SD card responds with illegal command (0x04) when I send Write_Block (or Read_Block)
As a last step of initialization you may want to explicitly set block length to 512 with CMD16 before trying to access the card for read or write.

Edit: as this quick possible fix did not work, let's make deeper troubleshooting:


try another card, better several if you have, to see if any of them work; this way we may able to figure out if issue is related to card or its interoperability with your code;
Check that you send correct CRC for the CMD17/CMD24 command. Illegal command is the response if CRC is wrong;
After CMD17/CMD14 fails, issue CMD13 command to get R2 status - card may be locked or experience ECC errors;
Read OCR register to see if card can operate at voltage you supply (in particular card's memory array, not just its SPI interface and its controller);
I would also read CID and CSD to see what it contains for the card.