What prevents someone from making the transaction on the lightning network, as well as the btc blockchain before the lightning network syncs up?
But the way this swap happen trustlessly between onchain and LN channel funds it's complicated, I don't have it clear right now
If you want to get an idea how later the balances updates happen trustlessly see my other comment https://news.ycombinator.com/item?id=27451184
So attacker could potentially do this but if they get caught they get punished for losing everything and they get caught if the other side node is online when this happens. There are also watchtowers that can monitor the network for hacks like this