Extended random phase approximation method for atomic excitation energies from correlated and variationally optimized second-order density matrices