You don’t mention what operating system you are using, but I am going to assume it is Windows.
There are numerous posts on this forum about a random Windows update that causes the permission for Audacity to use a microphone to be reset, so the permission has to be given again in order for Audacity to use it.