The first and second way always requires you to do parentheses first because of PEMDAS. Parentheses, exponents, multiplication and division (if division comes before multiplication in a problem, you would do division first), then addition and subtraction (same rule with division and multiplication).
first way:
4(x-2)=40-2x
4x-8=40-2x
6x-8=40
6x=48
x=8
second way:
4(x-2)=40-2x
4x-8=40-2x
-8=40-6x
-48=-6x
8=x or x=8