Is there some way to manually establish precedence?
You are manually establishing precedence of library search by using the -L option.
Also what if I have /foo/Y.a and /bar/Y.a, and LDFLAGS=-L/foo:/bar
What will happen then?
It will look in the directory /foo:/bar before the default library paths. It's not clear from your question if Y.a is actually supposed to be linked to anything.
What will AC_CHECK_LIB do? Is .dylib guaranteed to take precedence over .a? Vice versa? Random?
It won't be random, but will be influenced by other options given to configure (e.g. LDFLAGS, --disable-shared, etc.). All AC_CHECK_LIB does is plop in the name of the selected function into a main function (with appropriate libraries added) and see if it links.