Frameworks are built with programming languages and provide a standard and structured way of building web applications. Frameworks promote design patterns, code reuse, best practices and reduce development time.
Frameworks are used for rapid application development whereas CMS is an application in itself. Like any other application, CMS is built with Frontend and Backend technologies that include frameworks among other things.
With that said, CMS and frameworks can be compared only with regards to choosing a development path - whether to pick a CMS for developing a website and deal with possible limitations when serious customization will be required or use a framework and build a website that fully meets your requirements.
Both approaches have benefits and disadvantages. The choice depends on the business requirements, for example, time to market, usage of specific technologies or even on personal preferences.
CMS development is fast but it uses specific technologies and architecture that you can’t change while with frameworks you can pick any technology and architecture you like and have unlimited customisation options at the price of slower development.
For example, if you pick WordPress, you will use PHP and MySQL or MariaDB database and will be limited to its monolithic architecture and specific hosting providers. While going with a framework gives you tons of options for Frontend and Backend technologies as well as architectures and deployment options.