The smart way to move your head coming forward is out of the way of the punch that's coming at it. In short, you need to be balanced enough that you can continue your forward momentum without compromising your base. If your weight gets too high (on tippie toes), to far forward (ahead of your base, chasing) or your leaning to far to either side (separating upper body from lower) you can't make the adjustments with your head movement or footwork to sustain a meaningful attack without compromising your defense. I.E: "chase the man, not the hand"
There's a difference between stalking an opponent that's retreating vs. attacking an opponent who's backing up (swarming). Both have their place and are effective techniques. Stalking an opponent has more to do with positioning, as others have noted, cutting off the ring, using angles, jab, feints....etc..... IMO (at least the way I see it) Stalking an opponent is more a defensive strategy, since your opponent is capable of being offensive too. I.E, your battling for position, so punching coming forward is more about setting up a positional advantage (hence, jab in) to attack from vs attacking coming forward.
Aggressively attacking by coming forward or swarming an opponent is more a purely offensive technique, but doesn't have to be defensively compromising (if done properly). The idea being that you have to create a situation where your opponent is on the defensive while retreating (I.E: He's "rocked" or hurt). If your able to get in underneath your opponent (stand him up) and get him backpedaling on his heels, that's when it's appropriate to rush forward throwing shot's. The tricky part is being able to recognize when your opponent is no longer purely defensive and can pose an offensive threat (far from boxing 101 and very difficult to do consistently).
You've got to recognize when he re-establishes his base (good way to recognize this is when he's able gets his rear leg back and/or there's a slight drop in his elevation). So if you watch guys like Amir Khan, Kovalev, Manny they are all very good at attacking by coming forward fast and aggressive. But it's also what's got those same guys caught with big shots, it's difficult to recognize that "instant" that an opponent can re establish his base and pose an offensive threat. Andre Ward and Tim Bradley are both exceptionally good at doing this as well but still remaining more defensively sound vs Khan or Manny compromise their defense far more but their hand/foot speed allows them to get away with it.