It is not correct. It doesn't make any sense to say that, unless, in context, some way they could have done that is evident. For example, if there were a playground with a sandpit near the beach, and they built the sandcastles in that, you could say they built the sandcastles by the beach. But if they built their sandcastles from beach sand, then they built them on the beach, not by the