Remove out = out.view(out.size(0), -1) from your forward method amd you will get an output shape of [batch, 3, 218, 218].
.view works like reshape in numpy. So basically you are flattening your output, which gives [batch, 3*218*218=142572].
If you need the same width and height (224) in your output, change the padding in your conv layers, i.e.:

padding=1 for kernel_size=3
padding=2 for kernel_size=5

Since kernel_size=4 is even, it’s a bit more complicated, because it will change the output size by +/-1 for padding=1/2.
In your case, you could leave padding=1 in layer1P and set it to padding=2 in layer2P for kernel_size=4 and you will get an output with the shape [batch, 3, 224, 224].