Right Hand Thumb Rule
If thumb of right hand is placed in the direction of current flowing in the wire and the fingers are curled around the thumb then the direction of curl of fingers is always shows the direction of magnetic field.
SO in first figure
If we put our thumb in the direction of flowing current then magnetic field around that wire is showing by curl of fingers which is Clockwise in direction.
Similarly in second figure if we put our thumb in the direction of current then the curl of fingers is along Counterclockwise direction so its direction of magnetic field is also counterclockwise