LFI can lead to code execution

What are the conditions of when an LFI can lead to RCE, if any

What are the conditions of when an RFI can lead to RCE, if any

What are some general tips for securing against LFI/RFI?