Generally, Austrian trains are quite punctual and on time. However, two minutes to change a train is really tight, and 4 minutes isn't really better. The train station in Schwarzach-St.Veit is quite small and this will enhance your chance that you will catch the train. On the other hand, the train station in Salzburg is quite big, so if you're unlucky, there is a chance that you have to cross the whole train station to reach the appropriate track.
When you check the connections at oebb.at, you can see, that this connection is proposed by ÖBB. This means, it is a guaranteed connection. And even, if you will miss your connection, there are plenty of other connections, and you wouldn't have to wait too long. So if I were in your situation, I would take this connection. But I would make sure to tell the train conductor that you have to catch the train in St.Veit. If your train is not really late, it might be possible that he can make sure that your connecting train waits for you. The same applies for your leg from St.Veit to Salzburg.
(Btw: It is not too bad to spend a night at the station in St. Veit as I experienced myself on my trip to Hungary some years ago :) )