You are trying to use a variable that has not been declared yet. The use of containers helps with placing elements in the page in an arbitrary order, but the code still runs from top to bottom.
The only change you need is to place the st.empty containers inside the st.form and put the if logic outside the form, where the empty containers are actually filled up.
Code for the screen recording from before:
import streamlit as st
with st.form("form"):
first = st.text_input("First")
second = st.text_input("Second")
placeholder_radio = st.empty()
placeholder_additional_inputs = st.empty()
submit_button = st.form_submit_button("Submit")
with placeholder_radio:
show_questions = st.radio("Show questions", ("No", "Yes"))
with placeholder_additional_inputs.container():
if show_questions == "Yes":
third = st.text_input("Third")
fourth = st.text_input("Fourth")
if submit_button:
"**You submitted:**"
if show_questions == "Yes":
st.write(first, second, third, fourth)
else:
st.write(first, second)