Hello,
One of the first things to be mindful of when buying second hand is that the previous owner /store does a clean installation of the operating system and sets it up with your apple ID so that you're eligible for updates of software in your name.
The latest version of Logic Pro X requires Mac OS X 10.11 El Capitan or newer which is 10.2 or macOS Sierra
If you acquire a mac with 10.11 and it's setup with your apple ID, then you can purchase Logic and get a free update to macOS 10.12 from the app store.
Macs that are compatible with macOS Sierra are listed here:
https://www.apple.com/macos/how-to-upgrade/
You'll need to acquire a new audio (and MIDI) interface as drivers for your M-Audio devices will be non-existent for Mac OS X 10.11 or macOS 10.12. Firewire 800 interfaces (now considered a legacy technology) will work with Thunderbolt ports on a mac via a firewire-to-thunderbolt adapter. Thunderbolt interfaces will only work the thunderbolt ports on the mac. USB 2 or 3 interfaces are also an option.
What is your intended workflow? Recording mostly audio tracks processed with Logic plug-ins? Or mostly software instrument tracks? Using software instruments and lots of plug-ins will require more processing power than recording and editing audio.
A quad core i7 processor is best to run software instruments. A minimum of 8GB RAM (16 is better), a fast internal drive for operating system and applications (SSD is recommended), and a separate hard drive (internal or external ) to record your projects to which can be a 7200 rpm mechanical drive. An iMac, MacBook Pro, Mac Pro or a 2012 Mini are models to look at.
There are lots of options to consider, do your homework to ensure the mac, OS, Logic, and audio interface drivers all work together.