Artificial intelligence’s rapid advances have lawmakers racing to manage risks, alongside its business and social benefits.