By default imshow creates window object with WINDOW_AUTOSIZE attribute. It means that window size is determined by some frontend (GUI) which OpenCV was compiled with.
Your image are not actually changed, it is just displaying issue.
If you want to manually control window attributes, you can try to create namedWindow with your attributes before imshow call, i. e. something like this:
cv2.namedWindow("window name", cv2.WINDOW_NORMAL)
cv2.imshow("window name", img)
According to documentation there are 3 attributes for window displaying (WINDOW_NORMAL, WINDOW_AUTOSIZE and WINDOW_OPENGL), but with the following simple snippet you can determine your actually supported values (in my version I see WINDOW_FREERATIO, WINDOW_FULLSCREEN, WINDOW_AUTOSIZE, WINDOW_NORMAL, WINDOW_KEEPRATIO and WINDOW_OPENGL):
[i for i in list(cv2.__dict__.keys()) if i[:6] == 'WINDOW']