How does the disk and file share witness work?
There is a good article on how cluster quorum works in Windows Failover Clustering here.

to summarise, for File Share or Cloud Witnesses, a witness log file is maintained with state information about the cluster, witnesses and quorum voting. Each node has a cluster service running that periodically checks in with the other nodes and the witnesses (depending on dynamic voting, node weighting etc) to validate the state and health of the cluster. If a node cannot communicate with other nodes, it will then verify connectivity with the witness, assess the witness log (if possible) and proceed from there with either taking control of the cluster or not.

For example, assume we have two nodes, Node A and Node B, and a File Share Witness (Witness A), with Node A the primary node in the cluster. If Node B, during a periodic health check, cannot communicate with Node A because a switch went down then it will try to verify cluster health by contacting the cluster witness (Witness A) and reviewing the witness log to determine health state.

If Witness A can still communicate with both nodes because it has a different path to Node A than Node B does, this information will be in the witness log and Node B will not try to assume the role of the primary node. Node A will also see this information in the witness log and continue normal operations.

On the other hand, if Witness A has also lost communication with Node A, this information will be in the witness log and Node B will try and assume the role of the primary node. Since Node A will not be able to communicate with Node B or Witness A in this scenario, its cluster service will have shut down to prevent split-brain from occurring.

A Shared Disk witness works almost identically, except the witness is highly-available storage connected to the cluster, so instead of a witness log the shared disk maintains a copy of the cluster configuration database on the disk instead of just a witness log. Behaviorally, the witness and node interactions are the same.