I alway use MAMP for local development and noticed that I can access the htdocs folder from the LAN. Is it easily possible for a hacker to access the htdocs folder or my mysql databases from outside the LAN if he gets to know my computers ip address?
Not likely. MAMP access from outside the LAN would be restricted to the access that you give.
If you allow port 80 or 8080 to be available outside the LAN, to the MAMP server, and map them up nicely, and you're internal IP is 192.168.1.21 and the outside IP is 22.214.171.124 and it's all configured, then all they can see is what you're serving.
If you give access for say....VPN or SSH, then they can just open a Terminal window, and
cd to the directory and see everything as per you can.
Though, you'd also need to ask yourself - what are the permissions of the relevant files? Are they 777 or 444 or 744, or what?
The bottom line is, there are many factors involved, and it's most likely that you haven't mapped any ports to the MAMP server through your router correctly, so it would be quite difficult for a hacker to get through to that server and see what you're running. Unless it's important - and they WANT to get in.