Ahmadi did an awesome job with his answer, I can’t top it!
But I thought I’d share some additional context, hope it’s useful
In both of your example sentences the word “randomly” does not come across as natural or how a native speaker would use it. Ahmadi explained that randomly means without a specific purpose or aim. With that in mind, in your first example sentence, there IS a specific aim: to hang out with a friend and drink a beer. Therefore using ‘randomly’ does not really fit. ‘Casually’ would be a better choice. In the second example, again there IS a specific aim/purpose: to fix someone’s plumbing. A better choice here would be ‘sporadically’; something that was done from time to time but not on a regular basis. —> ‘For two years I sporadically did some plumbing repairs but I’m not a full-time (or licensed) plumber.’