Can strengthening your abs at the gym help you not get inguinal hernias?

No. Inguinal hernias occur at natural weak points of the abdominal wall. We believe that chronic "wear-and-tear" can lead to a hole forming in the muscle in susceptible people, which manifests itself as a hernia. Therefore, what you think may be helping you can actually increase the risk of a hernia developing. In contrast, obesity is a risk factor, as well, so your best bet is aerobic exercise.
No. Inguinal hernias are a congenital problem. So the short answer is no!