It may be due to a build-up of lactic acid caused by alcohol, so it is important to drink alcohol in moderation.
Moderate drinking does not usually cause excessive effects on the body, but excessive drinking may lead to a build-up of lactic acid and even alcohol poisoning, so as soon as the discomfort of sore legs occurs when drinking alcohol, stop drinking immediately and it can usually improve with rest and time.