When I use a command block to teleport to the nearest entity, it teleports my player towards itself which creates an endless teleportation loop, which cannot be ended even by disabling commands.
For example, if I type a command to teleport to an arrow, it should teleport me to the arrow, but its not. Its teleporting me to myself.
Please provide the exact commands that you are using.