Your modem can only accept one input at a time. It will either be Wireless or Wired.
To achieve your objective, you will need to purchase a router to go between the Modem and the Mac. This is not a Mac caused probem, you would have the same problem with two PC's or two Mac's.
The Router will need to be wireless and the wireless capabilities of the Modem will need to be turned off.
That said, is your modem a router as well as a modem, some are?
A detail or two more would be helpful.
OS? on both machines.
Type of connection, presumably Broadband but is is DSL or Cable.

This can be done

P