The short answer is that VNI is globally significant within a fabric while 802.1q VLAN tags are locally significant to either a given VTEP or a port on that VTEP.
So - using your example of VNI 5020. In a simple case we can imagine two VTEP's that each locally map VLAN 20 to VNI 5020. Any port on either VTEP that is assigned to VLAN 20 (or has a trunk receiving frames tagged with 20) will either switch the frame locally or encapsulate it in VNI 5020 and send it to the other VTEP to decapsulate the frame into the local VLAN 20 broadcast domain.
Now let's consider a slightly more interesting case. On VTEP A we still map VLAN 20 to VNI 5020. On VTEP B, however, we map VNI 5020 to VLAN 502. At this point anything hitting VTEP B on VLAN 502 will either be locally switched or encapsulated in VNI 5020 to be sent back to VTEP A - which will, in turn, decapsulate the frame into its local VLAN 20. The net effect is that the devices in VLAN 20 on A are in the same broadcast domain as the hosts on VLAN 502 on B.
Now take this a step further with per-port significance. On VTEP A port eth1/1 any frame received with a VLAN tag of 20 will get mapped into VNI 5020, while on port eth1/2 a tag of 20 corresponds to VNI 5920. On VTEP B I map eth1/9 tag 200 and eth1/22 tag 308 to VNI 5020. All three ports across the two VTEP's will, again, be in the same broadcast domain.
So - the answer to your question is, again, global vs local significance. In some implementations I might be limited to a VTEP-wide tag to VNI mapping and thus only support 4000 subnets. The key thing is that I don't have to use the same 4000 on each switch. I could have 30,000 VNI's in use that I selectively map to VLAN ID's as needed. Or if I support per-port significance I could theoretically map 4000 unique VNI's multiplied by the number of ports on the box.
Q-in-Q can also map to this numbering space, but that's a separate topic and use-case. My suggestion would be that the real questions in this area have to do with the control plane in use to communicate what addresses and VNI's are where, L3 info, etc. This also tends to drive some of the particulars around per-port vs per-VTEP, especially for the operation of MLAG and similar (not to mention downstream spanning tree questions and the like).