The reply about Islam names foundational acts, while the reply about Iman names foundational beliefs. This teaching distinction highlights two emphases:
Islam — outward declaration and practices: testimony, prayer, zakat, fasting, and Hajj.
Iman — inward assent to Allah, angels, scriptures, messengers, the Last Day, and decree.
These are not interchangeable labels for two unrelated things. Religious practice and belief are connected. Prayer, for instance, is not simply a physical motion; it is worship undertaken with belief and intention.