What happens when you wrap a 3x3 kernel at the corners of an image?
There are three main attitudes when dealing with borders of images and filter kernels.


The simplest is to only process the pixels that have enough neighboring pixels. As a result, some pixels on the sides are left unprocessed, and the filtered image can be cropped.


The shape of the  filter can be adapted (notably in size) to fit the neighborhood of of the running pixel.
The image is extended to the appropriate size. There are many extension methods, from filling with zeroes or constant values to clever extrapolation.



Traditionally, symmetric or antisymmetric extensions are used in many cases, since this is quite consistent with the symmetries or antisymmetries of filter kernels themselves, and this can be performed efficiently. Wraparound is also performed, and sometimes implicit when using FFT filtering or discrete wavelet restoration. Due to discontinuities (the far ends of the image can be quite different), a preprocessing is advised (windowing, smoothing, background removal).