The Apple ID address is same as rescue mail address and if secondary authentication is set in which three answers for security questions , date of birth , rescue mail address and password are added , when you try to rest password using rescue mai the code goes to rescue mail account and it can't be accessed .
Then reset the password from iforgot.apple.com using the correct credentials correct answers for three respective questions , correct date of birth is essential and will be required in upcoming steps .
The rescue mail address is always added in the Apple ID account , sign in with Apple ID account , if it is not yet added create a web mail account say with gmail service https://support.google.com/accounts/answer/27441?hl=en
Make sure this mail address and password should be totally different than your Apple ID address / password see the section of rescue mail address in this article https://support.apple.com/en-in/HT201356 in the same Mac open a new tab ( press command and T keys ) sign in with your gmail account here in the web mail account you will see this code , come to the old tab in which apple id account is already opened , fill up the code in the fields and click on done to save .