I'm not quite sure what triggers your particular bug, but I think it is a bug that locks are created when you can't edit a page, I've created
FS#2265 for that problem for which I've also a solution I'll implement soon.
Concerning your problem: There seems to be some mismatch between the IP that is reported when you are viewing the source and when you try editing the page. Maybe there is also the problem that the IPs appear in a different order. Maybe you could add a debug message in the main.php file of the template you are using, e.g. <?php msg(clientIP()); ?>, you can add that right after (or before) the line with the call to html_msgarea(). (The lock checks checks if either the IP or the username matches the value stored in the lock.) Then you could see if the reported IP changes when you log in.