Coincidentally I recently watched these videos about this topic. Both great channels!
3D Guide - How to Build the Perfect Medieval Castle https://youtu.be/Syjg6PHYFBo?si=JceRfeOks3hOVqWu
How to Lay Siege to a Medieval Fortress (1000-1300) https://www.youtube.com/watch?v=aQ7hTNoK-OA&t=1900s