Class B RVs can cost more than larger RVs and motorhomes primarily due to their compact size. Despite being smaller, they often come with all the amenities of a more extensive vehicle, including a bed, kitchen, bathroom, and other appliances. It takes more time and effort to fit these features into a small, smartly designed package.
They are also on a van frame (typically Mercedes, Ford, or Ram) that determines a good chunk of the cost, plus the included creature comforts. It can take more creativity and expensive components for everything to fit within the available space than in a larger rig.