As a guitar player, how do you know what fret to play when reading a music sheet?
It doesn't matter which fret, nor which string. It just has to be the correct note.
I believe you are referring to reading sheet music only without the tab at all.
If so, I would recommend starting with looking at the full range of the song or some sections of it.
The lowest and highest notes you need to get to. However, there are various ways, also including open strings or not for let ring vs muted styles etc. Long topic but looking at the lowest and highest notes should help to determine where you want to be.
It also depends on some shapes that might be relevant for the song like chord forms, arpeggios and sweeps.
Furthermore, hammer on and other slide etc legato technique parts might force you to play more horizontally rather than vertically. Experience and practice helps of course but a tough topic.
It sometimes takes time to figure out the best way to play it. Hope this helps.