WordPress page template to show posts as per category dynamically

It sounds very much like you are trying to do something that WordPress already does? There is a template called ‘category.php’ that you can use. It renders any Category of posts, so it accepts the category dynamically. Assuming you want all Category pages to render the same way, it would mean creating one file for any Category you have now or create in future.

Have a quick look at the WordPress template hierarchy to see how this all works.

Template hierarchy

And also, here is a default Category template.

Category template

You can also create category specific templates using category names or IDs in the file name, to override the output. All explained in the above.

Does that help you in the right direction?