Why would it do that? Because you coded it that way.
You must have some button with focus set and/or the Enter key is assigned. Which way do you want it to work, with the mouse or with the enter key. Do you want the dialog box to pop up all the time no matter if using the mouse or the Enter key? Look for a control with a key assignment.