The closest stop is Oceanside. This is probably 7-10 miles from Legoland. The Coaster goes from Oceanside to carlsbad pointesetta station, about 2 miles from Legoland. It's a commuter that runs morning to evening every half hour. To complicate things more in Oceanside you can transfer from the Coaster to Metro which goes to Anaheim also about every 30 minutes.
Near Legoland is The Grand Pacific Palisades Resort. But between the Carlsbad pointsetts station and Legoland is a few other hotels/motels, a couple are just across the road from the beach.
The is also a Carlsbad village station that the coaster serves. This is about half way between the Oceanside and pointsetta stations. It has lots of hotels near it.