How can I find what program is preventing my Mac from going to sleep?
You’ve done a pretty good job so far of troubleshooting this yourself and there are many things that prevent sleep out of the box and by design. 

What I would do next is exactly what you’re asking about - a targeted check to see if an application is what’s stopping your Mac from going to sleep.

To do this, follow these steps:


The next time your Mac isn’t going to sleep, open Activity Monitor
Click on the Energy tab
Now you’ll see a list of applications with a number of columns, one of which should be headed “Preventing Sleep”
Now check to see if any applications have a “Yes” listed in this column


IMPORTANT: If an application has an expansion triangle to the left of its name, make sure you expand it to confirm whether anything is preventing your Mac from going to sleep. For example, web browsers such as Safari often have multiple windows/tabs open and one of these could be preventing your Mac from going to sleep. However, this will not be obvious unless you click on the expansion triangle.


If so, you can force them to Quit by selecting them and pressing optioncommandQ
Now wait to see if your Mac will go to sleep


Notes: 


If you don’t see a “Preventing Sleep” column at Step 3, then go to View > Columns > Preventing Sleep to display it.
If no applications are listed as preventing sleep, then let me know via the comment box below and we'll proceed with other steps.


For people that like command line options - there is an assertions log that shows what is going on - things that make the Mac think you are active, things that will block sleep, etc...

pmset -g assertions


This is the same information that the activity monitor shows, just more detail and you can see items come and go by letting the log run:

pmset -g assertionlog


One nice thing about command line is you can ignore everything that doesn't have "sleep" in it:

pmset -g assertionslog|grep -i sleep