I will confine my answer to Star Wars, as you are using that tag, and the question would be too broad if applied to Science Fiction at large.
Ships in Star Wars are not firing actual lasers, they are firing blasters:
Lucasfilm defines the blaster as "ranged energized particle weaponry".
This indicates that a blaster is emitting physical matter.
Turning to now Legends sources:
Instead of firing a coherent beam of light like the archaic laser, the blaster fired a compressed, focused, high-energy particle-beam that was very destructive, commonly referred to as a "bolt."
As one can see in the films, these bolts move at speeds well short of light, as we can see the bolts moving, and ships at short range are sometimes able to dodge them. Logically, we may thus conclude that:
- Even if no other factors are limiting the range of a blaster bolt, the particles which comprise it will lose coherence as they collide with the interstellar medium, or the thicker matter present within a star system. The same will be true of any energy component in the bolt.
- Moving at less than light speed, the bolt will not be able to travel a meaningful distance before it looses the bulk of its destructive potential.