It is easy to develop leggy tomato seedlings, especially when you are raising them in more northern situated regions. The tomato is originally a subtropical plant. Raising them outside this climate region requires compromises or special solutions.
Tomato seedlings crave for light. Like all other plants they will grow towards the strongest source of light which is usually the sun.
In most regions you need to start off your seedlings inside, when the days are still short and the sun isn't particularly strong. You are also often reduced to using a window sill. This is the most typical low cost solution to raising tomato seedlings.
While there is nothing wrong in growing your seedlings in front of a window inside your house it can pose some problems which facilitate the plant to become leggy.
It is usually pretty warm at the window (inside + direct sunlight). Also the light usually comes from only one broad direction. The warmth makes the seedlings grow too fast. They stretch more than that they build up strength and produce leaves. Moreover, the unidirectional source of light makes them grow towards that source. Combined this often leads to leggy tomato seedlings.
If you are growing your seedling in your window sill a simple solution is to regularly turn your pots 180 degrees. You plants now do not get used to one direction of light and need to compensate. You can also put a box or screen covered in foil behind your pots. It reflects the sunlight, and makes the seedlings grow straighter, because light is now coming from opposite directions. Both methods will prevent the plants from focusing all their growth towards one direction, but are far from perfect.
Another solution is to grow your plants under grow lights. You can do this anywhere. With grow lights you don't need to sacrifice your precious window space for your seedlings. Another advantage is that you now have more control over the temperature, especially when you use the more energy efficient LED lights. You can grow your seedlings in a cooler environment like your garage. The only heat source will now be the grown lights. The environment can now be controlled much more. A cooler environment limits the "stretch" growth and you get more compact darker green plants, which are more suitable for transplanting to outside environments.
Don't despair though if you end up with some leggy seedlings. There is something unique about tomato plants. All the fine hair on the stem of a tomato plant have the capability to develop into roots. If you have leggy seedling you can literally cover most of your plant stem with growing medium and everything that is underneath will transform into a beautiful root system. Tomatoes are truly wonderful plants.