In the context of image or, in general, signal processing, the kernels (or filters) are used to perform some specific operation on the image. For example, you can use a Gaussian filter to smooth the image (including its edges).
In the context of convolutional neural networks (CNNs), the filters (or kernels) are the learnable parameters of the model. Before training, the kernels are usually randomly initialised (so they are not "selected"). During training, depending on the loss or error of the network (according to the loss function), the kernels (or filters) are updated, so that to minimise the loss (or error). After training, they are fixed. The number of kernels that are applied to a given input (and more than one kernel is often applied) in a CNN is a hyper-parameter.
In both contexts, the words "kernel" and "filter" are roughly synonymous, so they are often used interchangeably. Furthermore, in both cases, the kernels are related to the convolution (or cross-correlation) operation. More specifically, the application of a filter, which is a function $h$, to an input, which is another function $f$, is equivalent to the convolution of $f$ and $h$. In mathematics, this is often denoted by $f \circledast h = g$, where $\circledast$ is the convolution operator and $g$ is the result of the convolution operation and is often called the "convolution" (of $f$ and $h$). In the case of image processing, $g$ is the filtered image. In the case of CNNs, $g$ is often called an activation map.
Have a look e.g. at Visualizing what ConvNets learn
for some info regarding the visualisation of the kernels learned during training of a CNN.