Is there a way I can delete a command block in minecraft. It always teleports me away when I get too close
Is it on a server, if so you can deactivate command blocks and then restart the server.
If you know the coordinates, you can block the block with air https://www.digminecraft.com/game_commands/fill_replace_water.php#:~:text=In%20Minecraft%2C%20you%20can%20use,blocks%20within%20a%20fill%20range.
This is where you should find the answer.
https://minecraft.fandom.com/de/wiki/Befehl/setblock
Either destroy by command or briefly deactivate commands on a server.
Make cheating out for a moment or ask a friend who will fly there for you