Just a note that operational upgrades (op-ups) are at the airline's discretion due to overbooking generally and you can't choose to be op-upped. You can opt for an upgrade with miles if you have miles and the airline has space available.
As et mentioned, miles are added per sector, which can comprise multiple flights, e.g. you mention 4 flights, which is probably AAA - DXB - BBB / BBB - DXB - AAA. In this case you have two segments, and each will be credited once flown usually within 4-8 hours after arrival, so if you require the 3rd flight (1st of the 2ng segment) to upgrade you won't yet have been credited with the miles for that flight, also as you earn miles for BBB - AAA not BBB-DXB AND DXB-AAA separately, though in the case of EK it works out to the same.