All results from an if-then-else statement have to be the same type (or throw an Error result as well)
Your Windows clause returns a string (“Running”,“Stopped”) but your aix returns a boolean True/False. You can refactor it a couple of ways, but you need to return the same types on both checks. Also, I don’t think your last “Not Present” does what you think - that’s an else for the second OS name check, not for the running process check. You don’t need the second os name check at all in fact.
You can try this
if (name of operating system as lowercase starts with “win”) then (exists service “teagent” whose(state of it ="Running")) else (exists process “twdaemon”)