We analyze nondipole effects arising in ionization and high-order harmonic generation for a two-dimensional hydrogen atom irradiated with either low- or high-frequency laser pulses. In the low-frequency case, the electron wave packet dynamics is dominated by rescattering processes within the laser pulse. Here both odd- and even-order harmonics are generated in the direction of the laser field propagation and polarization, respectively. For high-frequency pulses, such rescattering processes can be neglected. We demonstrate that a significant portion of photoelectrons is detected opposite to the laser pulse propagation direction as a consequence of their postpulse wave packet spreading and interaction with the parent ion. This is accompanied by rich interference structures formed in the momentum distributions of photoelectrons. Our results follow from the numerical solution of the time-dependent Schr\"odinger equation, which is based on the Suzuki-Trotter scheme with the split-step Fourier approach. The method relies on a Hamiltonian decomposition, where except for the components depending exclusively on the momentum or on the position operators, there are also terms depending on both momentum and position operators in particular configurations. We demonstrate that, as long as the latter does not depend on noncommuting coordinates of the momentum and position operators, nondipole effects in laser-matter interactions can be studied without applying extra approximations and unitary operations.