The input to the padding layer is defined as [left, right, top, bottom]:

padding ( int  ,  tuple ) – the size of the padding. If is int, uses the same padding in all boundaries. If a 4-tuple, uses (paddingLeft, paddingRight, paddingTop, paddingBottom)

In your case you are setting the padding to right (left + right in the second example), to that your width will be increased.