Welcome to the community, Sudipta! Thanks for sharing your question and code snippet—this is a common point of confusion with Streamlit forms.
The issue is that widgets inside an st.form only send their values to the backend when the form is submitted. This means that dependent widgets (like your state selectbox, which depends on the country selectbox) won’t update in real time as you change the country selection—they’ll only update after you hit the submit button. As a result, country always defaults to the first option until the form is submitted, and the state selectbox doesn’t update dynamically. This is expected behavior for forms in Streamlit, as described in the Streamlit forms documentation and confirmed by community discussions (example).
If you want the state selectbox to update immediately when the country changes, you need to move the country selectbox outside the form, so its value is available to update the state options before the form is submitted.