how to use the /execute command to make it so if a mob has a radius to another mob it will execute a /summon command
You should test that the minecart doesn't have a tag, then give it a tag and summon the primed tnt. This way it will only summon once Another option is to kill the minecart
For the commands it depends on your version of minecraft, I will assume 1.13, if you are in 1.12 let me know
execute as @e[type=minecraft:tnt_minecart,tag=!exploded] at @s if entity @e[distance=..1,limit=1] run function explode
Which calls this function
# explode.mcfunction
tag @s add exploded
summon minecraft:tnt ~ ~ ~