With hardware synths, assuming if you're using track echo to monitor the synth so you can e.g. hear effects working on it while recording, MIDI latency can be down to how long it takes the synth itself to convert MIDI to audio.
Some are really snappy, others less so and some digital ones vary depending on the patch or if they're being used in a multitimbral mode. The snappiness or otherwise of the synth's envelope attack can also be a factor.
To make things worse, every synth tends to have a slightly different response time. Daisy-chaining MIDI gear means each synth down the chain gets a slightly delayed MIDI feed compared to the one upstream of it and some MIDI interfaces can add a little latency of their own as well. MIDI being a serial protocol this kind of thing is unavoidable. There's also the issue of how stable the MIDI clock controlling everything is as well, DAWs tend not to be 100% solid in that regard and the clock they send can and generally does drift by tiny fractions of a beat. Which again can cause discrepancies between the visual location of MIDI commands in the sequencer and the resulting recorded audio
If you've only one synth and the MIDI to audio offset is consistent then the global setting can be used to correct for it. If (like me) you use several hardware synths then nudging the audio over if the offset is an audible issue is the way to go. Personally I find that so long as things are within 3 or 4 milliseconds it's usually not worth bothering about, no human player's going to be any more accurate than that and a little timing discrepancy between tracks helps make things a bit less robotic.
Another option, especially if dealing with sounds with obvious transients and a fast attack, is to use audio quantising such as audiosnap on the recorded audio, but it's often quicker to just nudge the data to where it "should" be.
Or get rid of the problem by using hardware sequencers and voltage-control rather than MIDI, but they come with entertaining habits and limitations of their own and you still need a rock-solid MIDI source clock or there will still be some drift.