How MIUI releases based on different Android versions have same features? I would like to know how MIUI can provide features on all devices that have the same version of MIUI on it, without the same Android version?
Android version is mainly developed by Google. OEMs like Xiaomi modify AOSP to inject their own features. Other OEMs like Samsung, Huawei also do the same but they don't make visual changes as much as Xiaomi does. Even community based ROMs like Lineage, Omni and their offshoots like AOSP Extended, Resurrection Remix also have an almost standard set of modifications which they do to every AOSP release.

You can also customize AOSP to build a ROM of your own choice with required features.