There are multiple reasons that this could happen, but I have one reason that may be the most likely.
You had a full party when you caught it. When you caught Lugia, you might have had a full party, so Lugia was automatically transferred to your PC. Try checking all of your PC boxes and look for the below sprite.
Another thing that could have happened was you didn't save, but you did once have Lugia. Somebody could've traded Lugia to you and you traded it somewhere.
Hope this Helps!