Yes, I have a clue: check your sudo configuration.
Very likely your sudo is set up in a way it is requiring an TTY for command executions. When Ansible sends a command it uses ssh, which usually does not provide a TTY.
ansible -a “systemctl status docker” -i hosts -u user --ask-pass -K --become
Adding (–become) makes ansible responsible for executing sudo (default become method) and passing in a password if needed (-K prompts you ahead of time for the sudo password)