Editing the raw HTML isn’t going to work, a worst case scenario is it fails block validation when reopened in the editor and your edits get replaced automatically.
Instead, use the anchor
box under the advanced panel. Since the HTML of an embed usually comes from a 3rd party via OEmbed, you can wrap the embed block inside a group block, and give the group block the anchor.
E.g.
Note that “group block” is just a standard block of type group that comes with core. There are multiple ways to create them but they are just blocks that contain things, and can be found in the block picker/inserter. Any block that contains things/has children and can take an anchor attribute will also work. E.g. Column blocks, cover images, etc but group blocks are the simplest and least intrusive:
Remember, when building things with lego bricks you don’t get a chisel out and carve the shape you want into the brick, you build what you want out of many smaller blocks. WP blocks are the same, don’t modify blocks, combine and use them as building bricks to create what you actually want.