Constellations are simply patterns of stars that appear close to each other in the sky from our perspective on Earth. In reality, the stars in a constellation can be vastly different distances from us. Some may be relatively close, while others might be light-years apart.
Imagine looking at a group of trees in a forest. They might appear close together from your viewpoint, but in reality, they are spread out over a large area. Constellations are similar; they are just groupings of stars that seem close together from our vantage point on Earth.