Let's take this in 2 parts:
I understand that a server can run services (such as nginx) then
listen to localhost, then run Tor Server to create a unique tor
address and accept traffic from other Tor Servers into it.
My question is: is that server safe? Can someone trace the IP?
If your code isn't safe then it is not. It's all up to you.
Scenario A: Assume I'm running a website on tor network. Tor users
send a request to my server through N nodes. Does that mean (N-1)th
node's owner knows my IP and (N-2)th node owner's
IP? Scenario B: Suppose someone owns all N nodes, does that mean he
has the power as ISP on tor network?
A. No, the node doesn't know your IP. It just knows that you are listening to a specific address at a specific port. It doesn't do anything with your actual IP. Please read the design document to get a good understanding of Tor circuits and streams.
B. If someone owns all of the nodes and the Tor Project hasn't blacklisted the nodes, then Tor should not be used at all. This has never happened and in fact there are teams at the Tor Project out there working to make sure that this isn't the case.
I'm curious about this problem after reading FBI and The Playpen Case
since no one technically talks about this, how did the FBI hack trace
the owner server?
Actually there has been quite a lot written about this. They found him through normal police work. He was sloppy and stupid and the police didn't even have to trace his site. They just needed to trace him.