Why do I have more flash (STM32F103RCT6) than what my datasheet says?
All MCUs in a family or a family line are made on the very same silicon die. 512KB, and 256KB, and other MCUs are physically the same thing, however when you have 8 million transistors or more, some of them will not work, or will not work reliably, or will not work reliably at a particular temperature, or in the case of flash memory will not retain your information long enough.

Most likely your MCU started its life as a 512KB part, but during manufacturing testing it turned out that only 256KB are reliable across all operating conditions. The manufacturer probably does not have a facility in the chip to disable half of the flash, so only the identification bits are written accordingly and the programmer is expected to obey them.

Another hypothesis: it can be a counterfeit part (512KB) that was rejected from the factory, but someone found that 256KB is "good enough" and relabled it.