The phrase 'What was I thinking?' is used to show the speaker made a mistake and regrets it. You can also say 'What were you thinking?' if listener thinks the speaker made a big mistake. Notice the following: