Extra outline on internal layer?

There is a connector outline which acts like a copper left on my layout. I think I can delete it cleanly (without messing everything else), but why it is there.
I deleted a 40 pin connector on my Schematic and now in layout its outline remains, but in internal layer and it works like copper.
This is one those unstable nightly versions [kicad-msvc.r24590.288a94f5aa-x86_64.exe]

The simple answer is that it is not possible to deduce the complete history of your PCB from looking at a screenshot.

Is it possible there was a 38 pin connector on your PCB before you put on the 40 pin connector?
What happens if you select that part and then depress e to examine it’s properties? What are the extra lines in the squares? Were these also in the footprint, and on which layer?

Did you do any “experiments” with copy / paste operations, or move between layers? Such things can have weird results, and when the result is not understood, it’s often easily forgotten you did it in the first place.

Maybe you can get a hint of how it happened by restoring and viewing old backups.

Or just delete it and continue with the next task.

It should not be possible to create odd drawings on internal layers. But in this case I think it is a problem with libraries used in Raspberry Pi compute model IO boards.