Foo is simply registered under no profile, it will always be instantiate regardless of the profile you are using in that environment. Spring only allow to create multiple beans within an XML file with the same id if they are in different <beans> sets so I don't think that is possible to overwrite the Foo bean if it is not inside a <beans> tag with a profile.
If no profile are defined, Spring will use the profile named default. But, a bean that is not inside a <beans> tag with a profile will not be registered under that profile. It only means that if you have something like the following XML and that no profiles are provided, beans with the default profile will be loaded as well as beans with no profile.
<beans ... namespace decelerations>
<bean id="foo" class="com.example.foo" />
<beans profile="default">
<bean id="bar" class="com.exmaple.bar" />
</beans>
</bean>