While apache servers main goal is to serve static files but it also serve those php and other dynamic stuff too. So what are the add ons or is it in build in apache, which makes apache to serve those dynamic content?
Also isnt there anything inside apache as a container?
No PHP developer would agree with you .
It's true that apache httpd is often used to offload static content serving off Tomcat for java web apps. But it's more commonly used as a standalone web server for PHP web applications.
However, PHP is an optional Apache module. In fact, every functionality in Apache httpd is a "module", except for the raw html/js/image file serving. You can run Apache httpd without PHP if you want, and make it serve just static content like HTML/js/images.
Another common module that allows httpd to serve dynamic content is the CGI module, usually used for perl based web apps.