This may be an old bug, if it has been confirmed and does not require an on-site investigation, please let me know.
I have seen some non-specific pages, they have a maintenance category and the category are displayed on that page, but they are not displayed in that category. Empty editing the page will refresh and solve the problem.
Case on zhwiki:
- https://zh.wikipedia.org/wiki/Template:Apple_software have: 分类:苹果公司模板软件模板 隐藏分类:有蓝链却未移除内部链接助手模板的页面 and the ... "wgCategories":["有蓝链却未移除内部链接助手模板的页面","蘋果公司模板","软件模板"], ... in page source.
- API query got: {"batchcomplete":"","query":{"pages":{"913100":{"pageid":913100,"ns":10,"title":"Template:Apple software","categories":[{"ns":14,"title":"Category:\u860b\u679c\u516c\u53f8\u6a21\u677f"},{"ns":14,"title":"Category:\u8f6f\u4ef6\u6a21\u677f"}]}}}}
- Category tree does not list the Template:Apple software.