Subtract audio to another audio suppose I have a sample of a snare and that snare is used in a song,¿ there is an algorithm or tool that detects the sound of the snare and subtracts it, that is to say that cancels its phase or eliminates it?.

the result would be the song without the snare sound.

this could also apply to (accordion trumpets or any other instrument)
That's a really hard problem. If you have access to the original snare stem and the amount of post processing (effects, panning, mastering) is moderate you may be able to pull some of it out with an adaptive filter.

There are a few commercial plug ins that do this type of thing, but they all have their strengths and weaknesses so it depends a bit on your specific needs