Measurements of long-range azimuthal anisotropies and associated Fourier coefficients for pp collisions at s =5.02 and 13 TeV and p+Pb collisions at sNN =5.02 TeV with the ATLAS detector