You can think of applying a point-wise, i.e. $1\times 1$, convolution with $F$ filters to a $H\times W\times C$ image (or feature maps, in general) as the application of a linear fully-connected layer (with $F$ units) to each spatial location of the input, resulting in $H\times W\times F$ tensor.
In general, you can see the application of a convolutional layer (regardless the kernel size) as a matrix multiplication between the kernel matrix, say $K$, and the flattened image matrix, say $I$, where: $K$ is a block diagonal matrix (you have zeros outside the diagonal) build by kind of stacking the kernel (the weights of the conv layer) $H$ times as follows:
then $I$ is obtained by flattening the input image. After the multiplication you reshape the results back to a 3d-tensor shape.
In the example you have a $1\times 2$ kenel (reddish vector), and a $3\times 3$ image. So, you should consider for the matrix multiplication a stack of $2\times 3$ kenels ($k\times W$, in general) and a reshaped image of size $(H\times W,1)$.
what happens under the hood of a NN framework, such as PyTorch, when the number of input channels is equal to the number of output channels?
For practical implementations I don't think the matrix formulation of conv layers is beneficial, especially if you consider GPUs which have many threads and you can basically let each thread access a location of the input tensor, compute the respective index in the kernel, do the product and finally sum. Now if $k=1$ (as in pointwise conv), the matrix $K$ is built from $1\times W$ matrices, stacked $H$ times, resulting in $(W\times H)\times H$ kernel matrix, which is also mostly sparse. Maybe with ad-hoc algorithms for sparse multiplication this operation may be convenient.