Formatting code requires a code block: Add Block > Text > Code:
You can find more information regarding formatting code at: https://wordpress.com/support/wordpress-editor/blocks/code-block/