The Geek Stuff shows you how to build a RPM package on CentOS/RedHat in 7 steps
Sometimes you might have access to an open source application source code but might not have the RPM file to install it on your system.7 Steps to Build a RPM Package from Source on CentOS / RedHat
In that situation, you can either compile the source code and install the application from source code, or build a RPM file from source code yourself, and use the RPM file to install the application.
There might also be a situation where you want to build a custom RPM package for the application that you developed.