Amplitude analyses of D0 → π+π−π+π− and D0 → K+K−π+π− decays