Lets start with a basic premise: HTML and CSS are ****NOT**** programming languages.
They are markup languages. A markup language tells *something* (in this case, a web browser) how to display something. There are other markup languages that work with printers.
The difference between a markup language and a "real" programming language is that markup languages (generally) don't have the ability to perform logical operations. You just ***CAN NOT*** do a simple if statement in HTML/CSS. So you can't, say...display this text in BRIGHT ORANGE, but only if today is Halloween.
You need a *real* programming language to do that. Once you determine that you need a *real* programming language to do what you want to do, the next question becomes: WHERE? Do I want to run my code on the client side (Let the browser do it), or do I need code on the Server side?
JavaScript lets you do simple stuff on the client side (inside the browser). Yeah, you could see if it's Halloween and twerk the css property of some text to make it orange in JavaScript.
But, what if you wanted to .... I don't know....Show a list of all people that visited your site on Halloween. And list all the comments they left. You can't do that with HTML/CSS. (they aren't programming languages). And you can't do that with JavaScript, because it only knows about what is going on in 1 users browser, not everyone's browser.
You need something server side to do that. You need a web server that stores info about what all the web browsers viewing your site are doing. AND...you need to store that information somewhere..
So...you need a server side programming language for starters, and you need a database to store stuff. PHP/MySQL is one choice for that. Not the only choice, and certainly not the best choice. But a viable choice. It's where most beginners end up once they've figured out that HTML/CSS is not a programming language. They need more....