Random generation of finite and profinite groups and group enumeration