Solve 4x4 Mastermind in exactly 5 steps
05AB1E, 38 33 32 bytes
-6 bytes thanks to Kevin Cruijssen!
For each possible output this generates the input and selects the matching one. Colors are encoded as B=0, G=1, R=2, Y=3.
3Ý4ãʒU•˜ÐÐÛ•4в4äεœεX-0¢}¬Dràα‚}Q

Try it online!
Commented:
3Ý4ã              # Generate all possible outputs
3Ý                # range [0 .. 3]
  4и              # to the 4th cartesian power

ʒU ... Q          # filter the possible outputs
                  #   where the following equals the input
                  #   and assign the current output to variable X

•˜ÐÐÛ•4в4ä        # encode the 4 guesses
•˜ÐÐÛ•            # compressed integer 2517300803
      4в          # convert to base 4:
                  #   [2,1,1,2,0,0,2,2,3,3,1,2,1,0,0,3]
        4ä        # split into 4 groups:
                  #   [2,1,1,2],[0,0,2,2],[3,3,1,2],[1,0,0,3]
       &#32;
εœεX-0¢}¬Dràα‚}   # compute the score for each guess
ε             }   # map over the guesses ...
 œ                #   take all permutations
                  #     the first will be the original guess
  ε    }          #   map over the permuations ...
   X-             #     subtract the current output
     0¢           #     count the 0's
        ¬         #   get the head without popping
                  #     this is number of correct positions (c)
         D        #   duplicate it       =&gt; c, c, [...]
          r       #   reverse the stack  =&gt; [...], c, c
           à      #   take the maximum&#32;
                  #     this is number of correct colors,
                  #     correct and misplaced (c+m)
                  #                      =&gt; c+m, c, c
            α     #   absolut difference =&gt; |c-(c+m)|, c = m, c
             ‚    #   pair up     =&gt; [c, m]