Gutenberg: How to check if a block is used in a paginated post?

The solution is simple:

has_block( 'simpetoc/toc, $YOUR_POSTS_CONTENT_OR_POST_ID )

https://developer.wordpress.org/reference/functions/has_block/

has_block( string $block_name, int|string|WP_Post|null $post = null )

There is no need to render the blocks to build a table of contents, nor should you do it that way.

Note that your current approach breaks user defined HTML anchors and doesn’t account for headings in nested blocks.