The Code Block is to display things just as you typed them, so it may encode to ensure no code actually executes.
The HTML block is the reverse – it is to execute code exactly as you typed it, so it doesn’t encode.
This is intentional, so you can either show or execute code, depending on your needs. 🙂