Two insidesOlder and larger SD cards are a small circuit board carrying a controller chip and one or more TSOP-packaged flash chips; when the controller dies, the flash chips are desoldered and read on a programmer directly. Newer and cheaper cards are a single sealed block, a monolith, with controller and flash inside one package; when it dies, the flash is read through test pads on the card's own board. The free look says which yours is.
The lock switch is read by the hostThe slider on the side moves nothing inside the card. A lever in the slot reads its position, and a loose or broken slider, or a worn adapter, reports the card as locked when it is not. SanDisk's own note on adapters says a loose adapter switch can slide to the locked position as the card goes in, and that the adapter should be replaced. A card that is write-protected with its switch open, and in a reader that is known good, has locked itself for a different reason, below.
The read-only lockSanDisk's support note says a card will write-protect itself to prevent data loss when the number of good blocks is lower than the preset threshold, and a Linux kernel patch of 2021 notes that some SD cards set permanent write protection due to lifespan or internal problem. The card is still readable, and that is the point: copy everything off now, because it will never be writable again, and the forum tools that force the lock off are the wrong move.
Battery death and the file tablesA camera writes a photograph in two steps, the data and then the directory entry and allocation table that point at it. A battery that dies, or a card pulled out, between the two leaves tables that no longer describe the data. The camera says card error; the computer says format. The data is intact and the tables are rebuilt on the image.