Buildings unlock when you level up your Castle. If you need to unlock a building and cannot, you probably need to upgrade your Castle.

For example, to unlock the Spell Forge, you need to upgrade your Castle to Level 4.