I am currently working on updating Spain to the latest OSM-data. I can not figure out what the problem here is though.
"Thus, there is a second level unit "Comunidad de Madrid", which is fine. However, this contains two third level units, namely "Comunidad de Madrid" and "Segovia". There is the bug."
The region Comunidad de Madrid only has one county in it according to Project-GC, it has the same name, Comunidad de Madrid.
Firstly, the province of Segovia is part of the Comunidad autónoma de Castilla y León (and is also correctly enumerated there as well). It should, therefore, not appear as subunit of "Comunidad de Madrid".
Segovia is a part of Castilla y León, just as you say it is. It is not a part of Madrid.
Secondly, the "Comunidad de Madrid" in reality contains only one third level unit = province, and this should be called simply "Madrid".
I assume you mean that the county Comunidad de Madrid should not have the same name as the region Comunidad de Madrid. It's however named Comunidad de Madrid in OpenStreetMap as well.
On a more technical level. Project-GC doesn't really have any connection where county X belongs to region Y. It calculates which region and county a geocache belongs to by looking at the geocache's coordinates and the polygon data we have. That could very well end up with a geocache belonging to region Madrid and county Ceuta, depending on how the polygon data look.
As a postprocessing job Project-GC also goes through its data on a daily basis. If 95% of the geocaches in county Ceuta belongs to region Ceuta and 5% to region Madrid, it will update the the cache data to have region Ceuta on all of them. This can create temporary glitches. This is however only an issue if the polygon data doesn't have the same border for regions and counties. Madrid/Ceuta is an extreme case that probably wouldn't happen. But for two neighboring polygons there are high risks of complications close to the borders.