It doesn't work because the HTML block isn't a raw arbitrary HTML block. At the end of the day, all HTML in a posts content is passed through security filters that strip out anything that doesn't appear in a whitelist of tags and attributes. Wether you entered those manually, they were inserted by a block, or entered into a custom HTML block is irrelevant.
This is why blocks that depend on style and script tags render those tags dynamically in PHP, or rely on APIs such as OEmbed.
If you want to write custom CSS for a specific page or block you have the following options:
- Use the advanced panel to add a HTML class to target from a static CSS file, block styles/variants can be used to make this easy and let the block editor show this with GUI buttons and previews
- Use the custom CSS box in the global styles editor or the customizer
- If your CSS is specific to a page, you don't have to put the CSS in that pages content, WordPress puts classes on the
<body> tag you can use to target, everything from
single, the post type, the template used, to classes containing the page name and ID so you can precision target a specific post with a CSS rule
Do keep in mind though, you do not want to store CSS or JS in post content, be that a post/page/template. This is for security reasons.