Read the complete instruction here
A standard 3 tier application consists of a database, storing data (obviously), an application server running business logic and the business logic and. The presentation layer.
Considering S/4 HANA as the whole solution (consisting out of all technical components) SAP HANA as the underlying database (not the full story, since SAP HANA has evolved more and more into a platform containing libraries for more efficient calculation and presentation) and SAP ECC (ECC stands for enterprise core component) as the technical core (app server) of the SAP versions before S/4 HANA. The difference: ECC could deal with different database platforms underneath (Oracle, DB/2, MS SQL and of course HANA). S/4 HANA only runs on top of SAP HANA.