How to get postId from the argument $block when register_block_type()?

The get_the_ID() function will return the id of the current post in the loop.
If your block is used on a single post page or in a post loop (archive page) you can use this.