You must consider that data must be loaded in this shape:
bsxchxwxh
bs = batch_size
ch= channels
w and h = width and height respectively
If you do not consider batch_size, set it to 1. In this regard, when you want to feed only one image to conv2d, the size of input tensor must be 1 x ch x w x h. In MNIST dataset you must consider the size as bs x 1 x 28 x 28.
I hope I could guide you